﻿''' <summary>
''' rtf表格类
''' </summary>
''' <remarks></remarks>
Public Class RtfTable
    Private NoneValue As Double = -99
    Private NoneString As String = "-"

    Public Function tableheadstart() As String
        Dim a1 As String = "\trowd"
        Return a1
    End Function
    ''' <summary>
    ''' 写入表格边距信息，需要点声源、建筑物等标志Flag信息，第几行
    ''' </summary>
    ''' <param name="Num">第几行</param>
    ''' <param name="allrownum">总行数</param>
    ''' <param name="flag">表示</param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function TalbeNum(ByVal Num As Integer, ByVal allrownum As Integer, ByVal flag As String) As String
        Dim a1 As String = ""
        Dim a2 As String = "", a3 As String = "", a4 As String = ""
      
        If flag = "pointsource" Or flag = "linesource" Then '点声源和线声源
            If Num = allrownum - 1 Then
                a1 = "\irow" + Num.ToString + "\irowband" + Num.ToString + "\lastrow" + " \ts15\trgaph108\trleft-108"
            Else
                a1 = "\irow" + Num.ToString + "\irowband" + Num.ToString + " \ts15\trgaph108\trleft-108"
            End If
            '第n行的边框宽度
            a2 = "\trbrdrt\brdrs\brdrw10 \trbrdrl\brdrs\brdrw10 \trbrdrb\brdrs\brdrw10 \trbrdrr\brdrs\brdrw10 \trbrdrh\brdrs\brdrw10 \trbrdrv\brdrs\brdrw10 "
            a3 = "\trftsWidth1\trftsWidthB3\trautofit1\trpaddl108\trpaddr108\trpaddfl3\trpaddft3\trpaddfb3\trpaddfr3"
            a4 = "\tbllkhdrrows\tbllklastrow\tbllkhdrcols\tbllklastcol"
        ElseIf flag = "areasource" Then '水平面声源
            If Num = allrownum - 1 Then
                a1 = "\irow" + Num.ToString + "\irowband" + Num.ToString + "\lastrow" + " \ts15\trgaph85\trleft-85"
            Else
                a1 = "\irow" + Num.ToString + "\irowband" + Num.ToString + " \ts15\trgaph85\trleft-85"
            End If
            '第n行的边框宽度
            a2 = "\trbrdrt\brdrs\brdrw10 \trbrdrl\brdrs\brdrw10 \trbrdrb\brdrs\brdrw10 \trbrdrr\brdrs\brdrw10 \trbrdrh\brdrs\brdrw10 \trbrdrv\brdrs\brdrw10 "
            a3 = "\trftsWidth1\trftsWidthB3\trautofit1\trpaddl85\trpaddr85\trpaddfl3\trpaddft3\trpaddfb3\trpaddfr3"
            a4 = "\tbllkhdrrows\tbllklastrow\tbllkhdrcols\tbllklastcol"
        ElseIf flag = "vareasource" Then '垂向面声源
            If Num = allrownum - 1 Then
                a1 = "\irow" + Num.ToString + "\irowband" + Num.ToString + "\lastrow" + " \ts11\trgaph28\trleft-28"
            Else
                a1 = "\irow" + Num.ToString + "\irowband" + Num.ToString + " \ts11\trgaph28\trleft-28"
            End If
            '第n行的边框宽度
            a2 = "\trbrdrt\brdrs\brdrw10 \trbrdrl\brdrs\brdrw10 \trbrdrb\brdrs\brdrw10 \trbrdrr\brdrs\brdrw10 \trbrdrh\brdrs\brdrw10 \trbrdrv\brdrs\brdrw10 "
            a3 = "\trftsWidth1\trftsWidthB3\trautofit1\trpaddl28\trpaddr28\trpaddfl3\trpaddft3\trpaddfb3\trpaddfr3" 'trpaddl28\trpaddr28\trpaddfl3\trpaddft3定义单元格左右上下边距
            a4 = "\tbllkhdrrows\tbllklastrow\tbllkhdrcols\tbllklastcol"
        ElseIf flag = "roadsource" Or flag = "roadsourcehead" Then '公路声源
            If Num = allrownum - 1 Then
                a1 = "\irow" + Num.ToString + "\irowband" + Num.ToString + "\lastrow" + " \ts11\trgaph57\trleft-57"
            Else
                a1 = "\irow" + Num.ToString + "\irowband" + Num.ToString + " \ts11\trgaph57\trleft-57"
            End If
            '第n行的边框宽度
            a2 = "\trbrdrt\brdrs\brdrw10 \trbrdrl\brdrs\brdrw10 \trbrdrb\brdrs\brdrw10 \trbrdrr\brdrs\brdrw10 \trbrdrh\brdrs\brdrw10 \trbrdrv\brdrs\brdrw10 "
            a3 = "\trftsWidth1\trftsWidthB3\trautofit1\trpaddl57\trpaddr57\trpaddfl3\trpaddft3\trpaddfb3\trpaddfr3"
            a4 = "\tbllkhdrrows\tbllklastrow\tbllkhdrcols\tbllklastcol"
        ElseIf flag = "barrier" Then '声屏障
            If Num = allrownum - 1 Then
                a1 = "\irow" + Num.ToString + "\irowband" + Num.ToString + "\lastrow" + " \ts11\trgaph57\trleft-57"
            Else
                a1 = "\irow" + Num.ToString + "\irowband" + Num.ToString + " \ts11\trgaph57\trleft-57"
            End If
            '第n行的边框宽度
            a2 = "\trbrdrt\brdrs\brdrw10 \trbrdrl\brdrs\brdrw10 \trbrdrb\brdrs\brdrw10 \trbrdrr\brdrs\brdrw10 \trbrdrh\brdrs\brdrw10 \trbrdrv\brdrs\brdrw10 "
            a3 = "\trftsWidth1\trftsWidthB3\trftsWidthA3\trautofit1\trpaddl57\trpaddr57\trpaddfl3\trpaddft3\trpaddfb3\trpaddfr3"
            a4 = "\tbllkhdrrows\tbllklastrow\tbllkhdrcols\tbllklastcol"
        ElseIf flag = "greenwood" Then '绿化带
            If Num = allrownum - 1 Then
                a1 = "\irow" + Num.ToString + "\irowband" + Num.ToString + "\lastrow" + " \ts11\trgaph57\trleft-57"
            Else
                a1 = "\irow" + Num.ToString + "\irowband" + Num.ToString + " \ts11\trgaph57\trleft-57"
            End If
            '第n行的边框宽度
            a2 = "\trbrdrt\brdrs\brdrw10 \trbrdrl\brdrs\brdrw10 \trbrdrb\brdrs\brdrw10 \trbrdrr\brdrs\brdrw10 \trbrdrh\brdrs\brdrw10 \trbrdrv\brdrs\brdrw10 "
            a3 = "\trftsWidth1\trftsWidthB3\trftsWidthA3\trautofit1\trpaddl57\trpaddr57\trpaddfl3\trpaddft3\trpaddfb3\trpaddfr3"
            a4 = "\tbllkhdrrows\tbllklastrow\tbllkhdrcols\tbllklastcol"
        ElseIf flag = "hcirleareaSource" Then '圆形面声源
            If Num = allrownum - 1 Then
                a1 = "\irow" + Num.ToString + "\irowband" + Num.ToString + "\lastrow" + " \ts11\trgaph57\trleft-57"
            Else
                a1 = "\irow" + Num.ToString + "\irowband" + Num.ToString + " \ts11\trgaph57\trleft-57"
            End If
            '第n行的边框宽度
            a2 = "\trbrdrt\brdrs\brdrw10 \trbrdrl\brdrs\brdrw10 \trbrdrb\brdrs\brdrw10 \trbrdrr\brdrs\brdrw10 \trbrdrh\brdrs\brdrw10 \trbrdrv\brdrs\brdrw10 "
            a3 = "\trftsWidth1\trftsWidthB3\trftsWidthA3\trautofit1\trpaddl57\trpaddr57\trpaddfl3\trpaddft3\trpaddfb3\trpaddfr3"
            a4 = "\tbllkhdrrows\tbllklastrow\tbllkhdrcols\tbllklastcol"
        ElseIf flag = "railwaysource" Or flag = "circlebuilding" Or flag = "DisperseRecpator" Or flag = "DisperseRecpatorHead" Or flag = "VertLineReceptor" _
            Or flag = "LineReceptor" Or flag = "VertGrid" Or flag = "Grid" Or flag = "ResultVertLineReceptor" Or flag = "ResultVertLineReceptorHead" _
            Or flag = "railwaysourceHead" Or flag = "building" Then '圆形面声源 圆柱形建筑物
            If Num = allrownum - 1 Then
                a1 = "\irow" + Num.ToString + "\irowband" + Num.ToString + "\lastrow" + " \ts11\trgaph57\trleft-57" '表格边距
            Else
                a1 = "\irow" + Num.ToString + "\irowband" + Num.ToString + " \ts11\trgaph57\trleft-57"
            End If
            '第n行的边框宽度
            a2 = "\trbrdrt\brdrs\brdrw10 \trbrdrl\brdrs\brdrw10 \trbrdrb\brdrs\brdrw10 \trbrdrr\brdrs\brdrw10 \trbrdrh\brdrs\brdrw10 \trbrdrv\brdrs\brdrw10 "
            a3 = "\trftsWidth1\trftsWidthB3\trftsWidthA3\trautofit1\trpaddl57\trpaddr57\trpaddfl3\trpaddft3\trpaddfb3\trpaddfr3"
            a4 = "\tbllkhdrrows\tbllklastrow\tbllkhdrcols\tbllklastcol"
        End If



 
        Return a1 + vbCrLf + a2 + vbCrLf + a3 + vbCrLf + a4
    End Function
    ''' <summary>
    ''' 每列宽度，需要点声源、建筑物等标志Flag信息，单元格宽度自动计算
    ''' </summary>
    ''' <param name="AllColNum">总列数</param>
    ''' <param name="Flag">写入表格的标记</param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function cell(ByVal AllColNum As Integer, ByVal Flag As String) As String
        '每个单元格控制信息
        '缇(Twips) （缇：计量单位，等于“磅”的 1/20，英寸的 1/1,440。一厘米有 567 缇。
        '  像素(Pixels) : 监视器或打印机分辨率的最小单位()
        '右键单击桌面，选择属性，选择“设置”选卡，单击高级按钮。
        '里面出现DPI设置。一般为“正常尺寸(96 DPI)”'DPI的意思就是 DPI (Dots per Inch)。因此我们可以得到如下换算公式
        '1 Pixel = 1440 TPI / 96 DPI = 15 Twips    '1 Twip = 96 DPI / 1440 TPI = 0.0666667 Pixels
        'Flag=pointsouce,点源表格

        Dim a1 As String = "", a2 As String = "", returanvalue As String = ""

        '点源表格
        If Flag = "pointsource" Then
            Dim Coldist(AllColNum - 1) As Double
            Coldist(0) = 508
            Coldist(1) = 1724
            Coldist(2) = 3640
            Coldist(3) = 5256
            Coldist(4) = 6872
            Coldist(5) = 7688
            Coldist(6) = 8304
            For i As Integer = 0 To AllColNum - 1
                a1 = "\clvertalc\clbrdrt\brdrs\brdrw10 \clbrdrl\brdrs\brdrw10 \clbrdrb\brdrs\brdrw10 \clbrdrr\brdrs\brdrw10 \cltxlrtb\clftsWidth1\clshdrawnil "
                returanvalue = returanvalue + a1 + "\cellx" + Coldist(i).ToString
            Next
        End If

        '线源表格
        If Flag = "linesource" Then
            Dim Coldist(AllColNum - 1) As Double
            Coldist(0) = 508
            Coldist(1) = 1724
            Coldist(2) = 3640
            Coldist(3) = 5256
            Coldist(4) = 6872
            Coldist(5) = 8304
            For i As Integer = 0 To AllColNum - 1
                a1 = "\clvertalc\clbrdrt\brdrs\brdrw10 \clbrdrl\brdrs\brdrw10 \clbrdrb\brdrs\brdrw10 \clbrdrr\brdrs\brdrw10 \cltxlrtb\clftsWidth1\clshdrawnil "
                returanvalue = returanvalue + a1 + "\cellx" + Coldist(i).ToString
            Next
        End If

        '水平面源表格
        If Flag = "areasource" Then
            Dim Coldist(AllColNum - 1) As Double
            Coldist(0) = 485
            Coldist(1) = 1655
            Coldist(2) = 2925
            Coldist(3) = 3495
            Coldist(4) = 5065
            Coldist(5) = 6635
            Coldist(6) = 8505
            For i As Integer = 0 To AllColNum - 1
                a1 = "\clvertalc\clbrdrt\brdrs\brdrw10 \clbrdrl\brdrs\brdrw10 \clbrdrb\brdrs\brdrw10 \clbrdrr\brdrs\brdrw10 \cltxlrtb\clftsWidth1\clshdrawnil "
                returanvalue = returanvalue + a1 + "\cellx" + Coldist(i).ToString
            Next
        End If
        '垂向面声源表格

        If Flag = "vareasource" Then
            Dim Coldist(AllColNum - 1) As Double
            Coldist(0) = 428
            Coldist(1) = 1484
            Coldist(2) = 3240
            Coldist(3) = 3696
            Coldist(4) = 5152
            Coldist(5) = 6608
            Coldist(6) = 8364
            For i As Integer = 0 To AllColNum - 1
                a1 = "\clvertalc\clbrdrt\brdrs\brdrw10 \clbrdrl\brdrs\brdrw10 \clbrdrb\brdrs\brdrw10 \clbrdrr\brdrs\brdrw10 \cltxlrtb\clftsWidth1\clshdrawnil "
                returanvalue = returanvalue + a1 + "\cellx" + Coldist(i).ToString
            Next
        End If


        '公路声源表格 表头

        If Flag = "roadsourcehead" Then
            Dim Coldist(AllColNum - 1) As Double
            'Coldist(0) = 457
            Coldist(0) = 5847
            'Coldist(1) = 1571
            'Coldist(2) = 3385
            'Coldist(3) = 3999
            'Coldist(4) = 4615
            'Coldist(5) = 5231
            'Coldist(6) = 5847
            Coldist(1) = 8603
            Coldist(2) = 11259
            For i As Integer = 0 To AllColNum - 1
                a1 = "\clvertalc\clbrdrt\brdrs\brdrw10 \clbrdrl\brdrs\brdrw10 \clbrdrb\brdrs\brdrw10 \clbrdrr\brdrs\brdrw10 \cltxlrtb\clftsWidth1\clshdrawnil "
                returanvalue = returanvalue + a1 + "\cellx" + Coldist(i).ToString
            Next
        End If

        '公路声源表格 正文表格
        If Flag = "roadsource" Then
            Dim Coldist(AllColNum - 1) As Double
            Coldist(0) = 457
            Coldist(1) = 1571
            Coldist(2) = 3385
            Coldist(3) = 3999
            Coldist(4) = 4615
            Coldist(5) = 5231
            Coldist(6) = 5847
            Coldist(7) = 6561
            Coldist(8) = 7275
            Coldist(9) = 7889
            Coldist(10) = 8603
            Coldist(11) = 9317
            Coldist(12) = 9931
            Coldist(13) = 10545
            Coldist(14) = 11259
            For i As Integer = 0 To AllColNum - 1
                a1 = "\clvertalc\clbrdrt\brdrs\brdrw10 \clbrdrl\brdrs\brdrw10 \clbrdrb\brdrs\brdrw10 \clbrdrr\brdrs\brdrw10 \cltxlrtb\clftsWidth1\clshdrawnil "
                returanvalue = returanvalue + a1 + "\cellx" + Coldist(i).ToString
            Next
        End If

        '建筑物表格 正文表格
        If Flag = "building" Then
            Dim Coldist(AllColNum - 1) As Double
            Coldist(0) = 457
            Coldist(1) = 1571
            Coldist(2) = 2785
            Coldist(3) = 3299
            Coldist(4) = 4813
            Coldist(5) = 5727
            Coldist(6) = 6841
            Coldist(7) = 8155

            For i As Integer = 0 To AllColNum - 1
                a1 = "\clvertalc\clbrdrt\brdrs\brdrw10 \clbrdrl\brdrs\brdrw10 \clbrdrb\brdrs\brdrw10 \clbrdrr\brdrs\brdrw10 \cltxlrtb\clftsWidth1\clshdrawnil "  '\clftsWidth1 自动设置单元格宽度\clftsWidth3\clwWidth2840
                returanvalue = returanvalue + a1 + "\cellx" + Coldist(i).ToString
            Next
        End If


        '屏障表格 正文表格
        If Flag = "barrier" Then
            Dim Coldist(AllColNum - 1) As Double
            Coldist(0) = 577
            Coldist(1) = 1951
            Coldist(2) = 4189
            Coldist(3) = 4823
            Coldist(4) = 5457
            Coldist(5) = 7078
            Coldist(6) = 8697
            For i As Integer = 0 To AllColNum - 1
                a1 = "\clvertalc\clbrdrt\brdrs\brdrw10 \clbrdrl\brdrs\brdrw10 \clbrdrb\brdrs\brdrw10 \clbrdrr\brdrs\brdrw10 \cltxlrtb\clftsWidth1\clshdrawnil "  '\clftsWidth1 自动设置单元格宽度\clftsWidth3\clwWidth2840
                returanvalue = returanvalue + a1 + "\cellx" + Coldist(i).ToString
            Next
        End If


        '绿化带表格 正文表格
        If Flag = "greenwood" Then
            Dim Coldist(AllColNum - 1) As Double
            Coldist(0) = 931
            Coldist(1) = 3072
            Coldist(2) = 6558
            Coldist(3) = 8697
            For i As Integer = 0 To AllColNum - 1
                a1 = "\clvertalc\clbrdrt\brdrs\brdrw10 \clbrdrl\brdrs\brdrw10 \clbrdrb\brdrs\brdrw10 \clbrdrr\brdrs\brdrw10 \cltxlrtb\clftsWidth1\clshdrawnil "  '\clftsWidth1 自动设置单元格宽度\clftsWidth3\clwWidth2840
                returanvalue = returanvalue + a1 + "\cellx" + Coldist(i).ToString
            Next
        End If

        '圆形面声源表格 正文表格
        If Flag = "hcirleareaSource" Then
            Dim Coldist(AllColNum - 1) As Double
            Coldist(0) = 492
            Coldist(1) = 1681
            Coldist(2) = 3619
            Coldist(3) = 4167
            Coldist(4) = 5463
            Coldist(5) = 6759
            Coldist(6) = 8697
            For i As Integer = 0 To AllColNum - 1
                a1 = "\clvertalc\clbrdrt\brdrs\brdrw10 \clbrdrl\brdrs\brdrw10 \clbrdrb\brdrs\brdrw10 \clbrdrr\brdrs\brdrw10 \cltxlrtb\clftsWidth1\clshdrawnil "  '\clftsWidth1 自动设置单元格宽度\clftsWidth3\clwWidth2840
                returanvalue = returanvalue + a1 + "\cellx" + Coldist(i).ToString
            Next
        End If



        '圆柱形建筑物表格 正文表格
        If Flag = "circlebuilding" Then
            Dim Coldist(AllColNum - 1) As Double
            Coldist(0) = 457
            Coldist(1) = 1571
            Coldist(2) = 2485
            Coldist(3) = 3399
            Coldist(4) = 3913
            Coldist(5) = 4827
            Coldist(6) = 5741
            Coldist(7) = 6455
            Coldist(8) = 7569
            Coldist(9) = 8283

            For i As Integer = 0 To AllColNum - 1
                a1 = "\clvertalc\clbrdrt\brdrs\brdrw10 \clbrdrl\brdrs\brdrw10 \clbrdrb\brdrs\brdrw10 \clbrdrr\brdrs\brdrw10 \cltxlrtb\clftsWidth1\clshdrawnil "  '\clftsWidth1 自动设置单元格宽度\clftsWidth3\clwWidth2840
                returanvalue = returanvalue + a1 + "\cellx" + Coldist(i).ToString
            Next
        End If



        '离散点表格 表头

        If Flag = "DisperseRecpatorHead" Then
            Dim Coldist(AllColNum - 1) As Double
            Coldist(0) = 3732
            Coldist(1) = 6240
            Coldist(2) = 8748
            For i As Integer = 0 To AllColNum - 1
                a1 = "\clvertalc\clbrdrt\brdrs\brdrw10 \clbrdrl\brdrs\brdrw10 \clbrdrb\brdrs\brdrw10 \clbrdrr\brdrs\brdrw10 \cltxlrtb\clftsWidth1\clshdrawnil "
                returanvalue = returanvalue + a1 + "\cellx" + Coldist(i).ToString
            Next
        End If

        '离散点表格 正文表格
        If Flag = "DisperseRecpator" Then
            Dim Coldist(AllColNum - 1) As Double
            Coldist(0) = 525
            Coldist(1) = 1770
            Coldist(2) = 3732
            Coldist(3) = 4568
            Coldist(4) = 5404
            Coldist(5) = 6240
            Coldist(6) = 7076
            Coldist(7) = 7912
            Coldist(8) = 8748
            For i As Integer = 0 To AllColNum - 1
                a1 = "\clvertalc\clbrdrt\brdrs\brdrw10 \clbrdrl\brdrs\brdrw10 \clbrdrb\brdrs\brdrw10 \clbrdrr\brdrs\brdrw10 \cltxlrtb\clftsWidth1\clshdrawnil "
                returanvalue = returanvalue + a1 + "\cellx" + Coldist(i).ToString
            Next
        End If

        ' 铁路声源表格 表头
        If Flag = "railwaysourceHead" Then
            Dim Coldist(AllColNum - 1) As Double
            Coldist(0) = 8697
            For i As Integer = 0 To AllColNum - 1
                a1 = "\clvertalc\clbrdrt\brdrs\brdrw10 \clbrdrl\brdrs\brdrw10 \clbrdrb\brdrs\brdrw10 \clbrdrr\brdrs\brdrw10 \cltxlrtb\clftsWidth1\clshdrawnil "
                returanvalue = returanvalue + a1 + "\cellx" + Coldist(i).ToString
            Next
        End If

        '铁路声源表格 正文表格
        If Flag = "railwaysource" Then
            Dim Coldist(AllColNum - 1) As Double
            Coldist(0) = 482
            Coldist(1) = 1667
            Coldist(2) = 2638
            Coldist(3) = 3609
            Coldist(4) = 4580
            Coldist(5) = 5994
            Coldist(6) = 6965
            Coldist(7) = 7936
            Coldist(8) = 8697
            For i As Integer = 0 To AllColNum - 1
                a1 = "\clvertalc\clbrdrt\brdrs\brdrw10 \clbrdrl\brdrs\brdrw10 \clbrdrb\brdrs\brdrw10 \clbrdrr\brdrs\brdrw10 \cltxlrtb\clftsWidth1\clshdrawnil "
                returanvalue = returanvalue + a1 + "\cellx" + Coldist(i).ToString
            Next
        End If



        ' 垂向线结果表格 表头

        If Flag = "ResultVertLineReceptorHead" Then
            Dim Coldist(AllColNum - 1) As Double
            Coldist(0) = 3193
            Coldist(1) = 5782
            Coldist(2) = 8369
            For i As Integer = 0 To AllColNum - 1
                a1 = "\clvertalc\clbrdrt\brdrs\brdrw10 \clbrdrl\brdrs\brdrw10 \clbrdrb\brdrs\brdrw10 \clbrdrr\brdrs\brdrw10 \cltxlrtb\clftsWidth1\clshdrawnil "
                returanvalue = returanvalue + a1 + "\cellx" + Coldist(i).ToString
            Next
        End If

        '垂向线结果表格 正文表格
        If Flag = "ResultVertLineReceptor" Then
            Dim Coldist(AllColNum - 1) As Double
            Coldist(0) = 562
            Coldist(1) = 2330
            Coldist(2) = 3193
            Coldist(3) = 4056
            Coldist(4) = 4919
            Coldist(5) = 5782
            Coldist(6) = 6645
            Coldist(7) = 7508
            Coldist(8) = 8369
            For i As Integer = 0 To AllColNum - 1
                a1 = "\clvertalc\clbrdrt\brdrs\brdrw10 \clbrdrl\brdrs\brdrw10 \clbrdrb\brdrs\brdrw10 \clbrdrr\brdrs\brdrw10 \cltxlrtb\clftsWidth1\clshdrawnil "
                returanvalue = returanvalue + a1 + "\cellx" + Coldist(i).ToString
            Next
        End If


        '垂向线接受点表格 正文表格
        If Flag = "VertLineReceptor" Then
            Dim Coldist(AllColNum - 1) As Double
            Coldist(0) = 690
            Coldist(1) = 2315
            Coldist(2) = 4083
            Coldist(3) = 4831
            Coldist(4) = 5984
            Coldist(5) = 8369

            For i As Integer = 0 To AllColNum - 1
                a1 = "\clvertalc\clbrdrt\brdrs\brdrw10 \clbrdrl\brdrs\brdrw10 \clbrdrb\brdrs\brdrw10 \clbrdrr\brdrs\brdrw10 \cltxlrtb\clftsWidth1\clshdrawnil "  '\clftsWidth1 自动设置单元格宽度\clftsWidth3\clwWidth2840
                returanvalue = returanvalue + a1 + "\cellx" + Coldist(i).ToString
            Next
        End If


        '线接受点表格 正文表格
        If Flag = "LineReceptor" Then
            Dim Coldist(AllColNum - 1) As Double
            Coldist(0) = 1000
            Coldist(1) = 3917
            Coldist(2) = 7641
            Coldist(3) = 8697

            For i As Integer = 0 To AllColNum - 1
                a1 = "\clvertalc\clbrdrt\brdrs\brdrw10 \clbrdrl\brdrs\brdrw10 \clbrdrb\brdrs\brdrw10 \clbrdrr\brdrs\brdrw10 \cltxlrtb\clftsWidth1\clshdrawnil "  '\clftsWidth1 自动设置单元格宽度\clftsWidth3\clwWidth2840
                returanvalue = returanvalue + a1 + "\cellx" + Coldist(i).ToString
            Next
        End If

        '垂向网格表格 正文表格
        If Flag = "VertGrid" Then
            Dim Coldist(AllColNum - 1) As Double
            Coldist(0) = 457
            Coldist(1) = 1771
            Coldist(2) = 3585
            Coldist(3) = 5399
            Coldist(4) = 7013
            Coldist(5) = 8627

            For i As Integer = 0 To AllColNum - 1
                a1 = "\clvertalc\clbrdrt\brdrs\brdrw10 \clbrdrl\brdrs\brdrw10 \clbrdrb\brdrs\brdrw10 \clbrdrr\brdrs\brdrw10 \cltxlrtb\clftsWidth1\clshdrawnil "  '\clftsWidth1 自动设置单元格宽度\clftsWidth3\clwWidth2840
                returanvalue = returanvalue + a1 + "\cellx" + Coldist(i).ToString
            Next
        End If

        '垂向网格表格 正文表格
        If Flag = "Grid" Then
            Dim Coldist(AllColNum - 1) As Double
            Coldist(0) = 513
            Coldist(1) = 1747
            Coldist(2) = 3093
            Coldist(3) = 4107
            Coldist(4) = 5896
            Coldist(5) = 7685
            Coldist(6) = 8697
            For i As Integer = 0 To AllColNum - 1
                a1 = "\clvertalc\clbrdrt\brdrs\brdrw10 \clbrdrl\brdrs\brdrw10 \clbrdrb\brdrs\brdrw10 \clbrdrr\brdrs\brdrw10 \cltxlrtb\clftsWidth1\clshdrawnil "  '\clftsWidth1 自动设置单元格宽度\clftsWidth3\clwWidth2840
                returanvalue = returanvalue + a1 + "\cellx" + Coldist(i).ToString
            Next
        End If

        Return returanvalue
    End Function
    ''' <summary>
    ''' 表格内容开头
    ''' </summary>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function CellcontentStartOrEnd() As String
        Dim a1 As String = "\pard\plain \ql \li0\ri0\widctlpar\intbl\aspalpha\aspnum\faauto\adjustright\rin0\lin0 "

        Return a1
    End Function
    ''' <summary>
    ''' 返回表格信息包括行设置和单元格设置
    ''' </summary>
    ''' <param name="Rownum">总行数</param>
    ''' <param name="RowSequence">第n行</param>
    ''' <param name="Colnum">总列数</param>
    '''  <param name="Flag">写入表格的表示，字符型</param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function RowEnd(ByVal Rownum As Integer, ByVal RowSequence As Integer, ByVal Colnum As Integer, ByVal Flag As String) As String

        Dim Rowrepeatstring As String = ""
        Dim a3 As String = tableheadstart()
        Rowrepeatstring = Rowrepeatstring + a3 '表格开头
        Rowrepeatstring = Rowrepeatstring + vbCrLf + TalbeNum(RowSequence, Rownum, Flag)  '行开头
        Rowrepeatstring = Rowrepeatstring + vbCrLf + cell(Colnum, Flag) + vbCrLf '单元格设置
        Return Rowrepeatstring
    End Function
    ''' <summary>
    ''' 表格内容，可传入文本，数组，数字
    ''' </summary>
    ''' <param name="strA"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Overloads Function CellContent(ByVal strA As String) As String
        Dim ReturanValue As String = ""
        If strA = "-99.00" Then
            ReturanValue = "{\f13\fs20 " + "-" + "\cell}"
        Else
            ReturanValue = "{\f13\fs20 " + StrToRtf(strA) + "\cell}"
        End If


        'End If
        Return ReturanValue
    End Function
    ''' <summary>
    ''' 主要为多个坐标点
    ''' </summary>
    ''' <param name="strA"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Overloads Function CellContent(ByVal strA() As String) As String
        Dim ReturanValue As String = ""
        For i As Integer = 0 To strA.Length - 1
            If i = strA.Length - 1 Then '如果是最后一行，则不写入换行信息
                ReturanValue = ReturanValue + "\f13\fs20 " + StrToRtf(strA(i) + "\cell}")
            ElseIf i = 0 Then '如果是第一行，则写入表格开始信息，就是多写一个“{”
                ReturanValue = ReturanValue + "{\f13\fs20 " + StrToRtf(strA(i) + "\par")
            Else
                ReturanValue = ReturanValue + "\f13\fs20 " + StrToRtf(strA(i) + "\par")
            End If
        Next

        Return ReturanValue
    End Function
    ''' <summary>
    ''' 主要是源强 dB，不分频的情况
    ''' </summary>
    ''' <param name="strA"></param>
    ''' <param name="flag"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Overloads Function CellContent(ByVal strA As Double, ByVal flag As String) As String
        Dim ReturanValue As String = ""
        '空值单独处理
        If strA = NoneValue Then
            ReturanValue = "{\f13\fs20 " + StrToRtf(NoneString + flag + "\cell}")
        Else
            ReturanValue = "{\f13\fs20 " + StrToRtf(Format(strA, "0.00") + flag + "\cell}")
        End If

        Return ReturanValue
    End Function
    ''' <summary>
    ''' 主要为 公路 车型比等
    ''' </summary>
    ''' <param name="strA"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Overloads Function CellContent(ByVal strA() As Double) As String
        Dim ReturanValue As String = ""
        For i As Integer = 0 To strA.Length - 1

            If i = strA.Length - 1 Then '如果是最后一行，则不写入换行信息
                If strA(i) = NoneValue Then
                    ReturanValue = ReturanValue + "\f13\fs20 " + StrToRtf(NoneString + "\cell}")
                Else
                    ReturanValue = ReturanValue + "\f13\fs20 " + StrToRtf(strA(i).ToString + "\cell}")
                End If

            ElseIf i = 0 Then '如果是第一行，则写入表格开始信息，就是多写一个“{”
                If strA(i) = NoneValue Then
                    ReturanValue = ReturanValue + "{\f13\fs20 " + StrToRtf(NoneString + "\par")
                Else
                    ReturanValue = ReturanValue + "{\f13\fs20 " + StrToRtf(strA(i).ToString + "\par")
                End If

            Else
                If strA(i) = NoneValue Then
                    ReturanValue = ReturanValue + "\f13\fs20 " + StrToRtf(NoneString + "\par")
                Else
                    ReturanValue = ReturanValue + "\f13\fs20 " + StrToRtf(strA(i).ToString + "\par")
                End If


            End If
        Next

        Return ReturanValue
    End Function
    ''' <summary>
    '''  分频  频率
    ''' </summary>
    ''' <param name="strA"></param>
    ''' <param name="Flag"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Overloads Function CellContent(ByVal strA() As Double, ByVal Flag As Integer) As String
        Dim ReturanValue As String = ""

        'flag=1 代表是频率，flag=2 代表是坐标点
        If Flag = 1 Then
            Dim flagHz(7) As String
            flagHz(0) = "(63hz)"
            flagHz(1) = "(125hz)"
            flagHz(2) = "(250hz)"
            flagHz(3) = "(500hz)"
            flagHz(4) = "(1000hz)"
            flagHz(5) = "(2000hz)"
            flagHz(6) = "(4000hz)"
            flagHz(7) = "(8000hz)"
            For i As Integer = 0 To strA.Length - 1
                If i = strA.Length - 1 Then '如果是最后一行，则不写入换行信息
                    If strA(i) = NoneValue Then
                        ReturanValue = ReturanValue + "\f13\fs20 " + StrToRtf(NoneString + flagHz(i) + "\cell}")
                    Else
                        ReturanValue = ReturanValue + "\f13\fs20 " + StrToRtf(Format(strA(i), "0.00") + flagHz(i) + "\cell}")
                    End If
                ElseIf i = 0 Then '如果是第一行，则写入表格开始信息，就是多写一个“{”
                    If strA(i) = NoneValue Then
                        ReturanValue = ReturanValue + "{\f13\fs20 " + StrToRtf(NoneString + flagHz(i) + "\par")
                    Else
                        ReturanValue = ReturanValue + "{\f13\fs20 " + StrToRtf(Format(strA(i), "0.00") + flagHz(i) + "\par")
                    End If
                Else
                    If strA(i) = NoneValue Then
                        ReturanValue = ReturanValue + "\f13\fs20 " + StrToRtf(NoneString + flagHz(i) + "\par")
                    Else
                        ReturanValue = ReturanValue + "\f13\fs20 " + StrToRtf(Format(strA(i), "0.00") + flagHz(i) + "\par")
                    End If

                End If
            Next
        End If


        Return ReturanValue
    End Function










    ''' <summary>
    ''' 将字符串转换成RTF编码
    ''' </summary>
    ''' <param name="strasc">任意字符串</param>
    ''' <returns>将字符串转换成纯ASCII的编码</returns>
    ''' <remarks></remarks>
    Private Function StrToRtf(ByVal strasc As String) As String

        Dim Zval As Integer = Val("z")
        Dim ret As New System.Text.StringBuilder


        For i As Integer = 0 To strasc.Length - 1
            Dim kk As String = strasc(i)

            If kk = "\\" Then
                ret.Append("\\\\")
            ElseIf kk = "\n" Then
                ret.Append("\\par ")
            ElseIf kk = "\" Then
                ret.Append("\")
            ElseIf kk = "'" Then
                ret.Append("'")
                '如果字符kk不是字符（是汉字） 则转化为ascii 编码
            ElseIf Asc(kk) < 0 Or Asc(kk) > 127 Then
                Dim targetEncoding As System.Text.Encoding
                Dim encodedChars As Byte()

                'Gets the encoding for the specified code page.
                targetEncoding = System.Text.Encoding.Default

                ' Gets the byte representation of the specified string

                encodedChars = targetEncoding.GetBytes(strasc(i))

                For j As Integer = 0 To encodedChars.Length - 1
                    Dim st As String
                    st = encodedChars(j).ToString
                    Integer.Parse(st).ToString("x")
                    ret.Append("\'").Append(Integer.Parse(st).ToString("X"))
                Next
                '如果是字符 则直接加入
            Else
                ret.Append(kk)
            End If
        Next

        Return ret.ToString

    End Function
End Class
